//
//  ImageCase.m
//  TestDemo
//
//  Created by fengxijun on 16/6/13.
//  Copyright © 2016年 goappbox. All rights reserved.
//

#import "ImageCase.h"
#import "UIImage+EffectKit.h"

@implementation ImageCase
{
    UIImageView *imageV;
    UIImageView *imageV1;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }
    return self;
}

- (void)setUp
{
    UIButton *t = [UIButton buttonWithType:UIButtonTypeCustom];
    [t setTitle:@"test" forState:UIControlStateNormal];
    [t setFrame:CGRectMake(10.0, 10.0, 50.0, 30.f)];
    [self addSubview:t];
    [t addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
    
    imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(t.frame) + 10.f, self.frame.size.width, self.frame.size.height - (CGRectGetMaxY(t.frame) + 10.f))];
    imageV.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:imageV];
    
//    imageV1 = [[UIImageView alloc] initWithFrame:CGRectMake(140.f, CGRectGetMaxY(t.frame) + 10.f, 200.f, 120.f)];
//    imageV1.contentMode = UIViewContentModeScaleAspectFit;
//    [self addSubview:imageV1];
}

- (void)test:(id)sender
{
    printf("CGImageGetTypeID : %lu",CGImageGetTypeID());
    UIImage *image = [UIImage imageNamed:@"tigger"];
    UIImage *maskImage = [UIImage imageNamed:@"tiggermask"];
    
//    [image effectedImage:^(unsigned char *pixels, EffectImageAttributes attributes) {
//    } finishBlock:^(UIImage *image) {
//        imageV.image = image;
//    }];
    
//    imageV.image = [image mosaicImageWithLevel:8];
    imageV.image = [image appendMask:[maskImage maskImage]];
//    imageV1.image = [[UIImage imageNamed:@"example1"] appendMask:imageV.image];
}

@end
